<?php

namespace App\Http\Validators\V1;

use App\Constants\CashConstant;
use App\Http\Validators\AbstractValidator;

/*
 *
 * 验证接口
 */

class HandBillValidator extends AbstractValidator
{

    /**
     * Validation rules
     *
     * @var Array
     */
    protected $rules = array(
        'money'   => ['required'],
        'item_id' => ['required','integer','is_rational'],
    );

    /**
     * Validation messages
     *
     * @var Array
     */
    protected $messages = array(
        'money.required' => 'umlah harus dimasukkan',
        'item_id.required' => 'Jumlah harus mempunyai dua decimal',
        'item_id.integer' => 'Item harus berupa angka',
        'item_id.is_rational' => 'Item harus berupa angka',
    );


    public function before()
    {
        // 判断所选栏目是否是有效的
        $this->extend('is_rational', function($attribute, $value, $parameters)
        {

            if($value>=0 && $value < 14 ){
                return true;
            }

            return false;

        });
    }
}
